package com.lanou.musicproject.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lanou.musicproject.R;
import com.lanou.musicproject.activity.SeekActivity;
import com.lanou.musicproject.bean.Seek;

import java.util.List;

/**
 * Created by dllo on 15/10/22.
 */
public class SeekGridViewAdapter extends BaseAdapter {
    private List<Seek.DataEntity>data;
    private Context mContext;
    private Seek.DataEntity entity ;
    public SeekGridViewAdapter(Context c, List<Seek.DataEntity> d) {
        mContext = c ;
        data = d ;

    }

    @Override
    public int getCount() {
        return data != null && data.size() >0 ? data.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return data != null && data.size() > 0 ? data.get(position) : null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.seek_item,null);
            holder = new ViewHolder();
            holder.seek_item = (TextView) convertView.findViewById(R.id.seek_item);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        entity = (Seek.DataEntity) getItem(position);
        if (entity != null){
            holder.seek_item.setText(entity.getVal());
        }

        return convertView;
    }
 private  class   ViewHolder{
    private  TextView seek_item;
 }
}
